﻿using LVYAN.Model;
using LVYAN.Model.AutoMation;
using LVYAN.Utils;
using System.Threading.Tasks;

namespace LVYAN.Service.AIAPI
{
    public class FileService : BaseAPI
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static FileModel Upload( string ImgPath)
        {
             
            new LoggerService().ResponseMsgDebug("上传附件", "发送消息-上传附件", ImgPath);
            var result = string.Empty;
            var action = Task.Run(async () =>
              {
                  result = (await new RequestService().Upload($"{AIAPI}Upload/Index", ImgPath));
              });
            action.Wait();
            var reponseData = JsonService.ToModel<FileModel>(result);
            new LoggerService().ResponseMsgDebug("上传附件", "接受消息-上传附件", reponseData);
            return reponseData;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static bool Down(string Url, string ImgPath)
        {
            new LoggerService().ResponseMsgDebug("下载附件", "发送消息-上传附件", ImgPath);
            var result = true;
            var action = Task.Run(async () =>
            {
                result = (await new RequestService().Down(Url, ImgPath));
            });
            action.Wait();
            return result;
        }
    }
}
